package com.bwie.controller;

import com.bwie.pojo.TbActive;
import com.bwie.service.TbActiveService;
import com.bwie.utils.R;
import com.bwie.vo.PageInfoVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @author 牛毅
 * @version 1.0
 * @date 2025/7/28
 * @description TODO
 */
@RestController
@RequestMapping("/active/index")
public class ActiveController {
    @Autowired
    TbActiveService tbActiveService;

    /**
     * @description: 获取活动列表
     * @param: pageInfoVo
     * @return: com.bwie.utils.R
     * @author 牛毅
     * @date: 2025/7/28 19:11
     */
    @PostMapping("/getActiveList")
    public R getActiveList(@RequestBody PageInfoVo pageInfoVo){
        return tbActiveService.getActiveList(pageInfoVo);
    }
    
    /** 
     * @description: 添加活动 
     * @param: tbActive 
     * @return: com.bwie.utils.R 
     * @author 牛毅
     * @date: 2025/7/28 19:49
     */ 
    @PostMapping("/addActive")
    public R addActive(@RequestBody @Validated TbActive tbActive){
        return tbActiveService.addActive(tbActive);
    } 
    
    /** 
     * @description: 删除活动
     * @param: activeId 
     * @return: com.bwie.utils.R 
     * @author 牛毅
     * @date: 2025/7/28 19:50
     */ 
    @PostMapping("/deleteById/{activeId}")
    public R deleteById(@PathVariable("activeId") Integer activeId){
        return tbActiveService.deleteById(activeId);
    }

    /**
     * @description: 修改活动
     * @param: tbActive
     * @return: com.bwie.utils.R
     * @author 牛毅
     * @date: 2025/7/28 19:53
     */
    @PostMapping("/updateActive")
    public R updateActive(@RequestBody TbActive tbActive){
        return tbActiveService.updateActive(tbActive);
    }
}
